/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package elevenHomework;

/**
 *
 * @author Administrator
 */

    

import java.util.LinkedHashMap;
import java.util.Scanner;
public class ProblemD {
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        LinkedHashMap<String,Integer> Sc=new LinkedHashMap<String,Integer>();
        while(in.hasNextLine()){
            String s=in.nextLine();
            if(s.isEmpty()){
                break;
            }
            Sc.put(s,0);
        }
        while(in.hasNextLine()){
            String ss=in.nextLine();
            if(ss.isEmpty()){
                break;
            }
            String c[]=ss.split(",");
            int a=Sc.get(c[0]);
                Sc.put(c[0], Integer.parseInt(c[1])+a);
        }
        for(String O:Sc.keySet()){
            int k=Sc.get(O);
            System.out.printf("%s=%d\n",O,k);
        }
    }
}
